package com.zy.Dao;

import com.zy.Domain.Province;
import com.zy.util.DruidToolClass;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.ArrayList;
import java.util.List;

public class ProvinceDaoImpl implements ProvinceDao
{
    @Override
    public List<Province> searchAll()
    {
        JdbcTemplate jdbcTemplate= new JdbcTemplate(DruidToolClass.getDataSource());
        String sql="select * from province";
        List<Province> list=new ArrayList<>();
        try
        {
            list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<Province>(Province.class));
        } catch (DataAccessException e)
        {
            e.printStackTrace();
        }
        return list;
    }
}
